package tt.dz.biz.dao.login;

import org.springframework.stereotype.Repository;
import tt.dz.biz.dao.BaseDAO;
import tt.dz.vo.MsLoginHisVO;
import tt.dz.vo.UserVO;

@Repository("loginDAO")
public class LoginDAOImpl
  extends BaseDAO
{
  private static final String QUERY_USER_BY_ACCOUNT = "select mub.user_id as userId, mub.mobile_no as mobileNo, mub.user_type as userType, mub.merchant_code as merchantCode, mub.login_times as loginTimes, mub.is_online as isOnline, mub.password, mub.is_locked as isLocked, mub.locked_time as lockedTime, mub.im_username as imUsername, mub.im_pwd as imPwd, mub.is_valid as isValid from ms_user_base mub where mub.mobile_no=:mobileNo";
  private static final String INSERT_LOG = "insert into ms_login_his(user_id,login_time,longin_ip,is_success,longitude,latitude,brand,terminal_type)  values(:userId,:loginTime,:longinIp,:isSuccess,:longitude,:latitude,:brand,:terminalType )";
  
  public UserVO queryUserInfo(String aUserName)
  {
    UserVO tmpVO = new UserVO();
    tmpVO.setMobileNo(aUserName);
    
    return (UserVO)queryForObject("select mub.user_id as userId, mub.mobile_no as mobileNo, mub.user_type as userType, mub.merchant_code as merchantCode, mub.login_times as loginTimes, mub.is_online as isOnline, mub.password, mub.is_locked as isLocked, mub.locked_time as lockedTime, mub.im_username as imUsername, mub.im_pwd as imPwd, mub.is_valid as isValid from ms_user_base mub where mub.mobile_no=:mobileNo", tmpVO, UserVO.class);
  }
  
  public int log(MsLoginHisVO aVO)
  {
    return save("insert into ms_login_his(user_id,login_time,longin_ip,is_success,longitude,latitude,brand,terminal_type)  values(:userId,:loginTime,:longinIp,:isSuccess,:longitude,:latitude,:brand,:terminalType )", aVO);
  }
}
